package masterjava.reporting.shared.entity;

import masterjava.common.shared.HasKey;
import masterjava.common.shared.entity.BaseEntity;

import javax.persistence.*;

/**
 * User: Grigory Kislin
 * Date: 23/06/11
 */
@Entity

@NamedQueries({
        @NamedQuery(
                name = AlgoStrategy.FIND_BY_USER_ID,
                query = "from AlgoStrategy asg where asg.userId=:" + AlgoStrategy.USER_ID+" order by name"
        )
})
@Table(name = "ALGO_STRATEGY")
@Access(AccessType.PROPERTY)
public class AlgoStrategy extends BaseEntity implements HasKey {

    private String name;
    private Long userId;

    public static final String FIND_BY_USER_ID = "FIND_BY_USER_ID";
    public static final String USER_ID = "userId";

    public AlgoStrategy() {
    }

    public AlgoStrategy(String name, Long id) {
        setId(id);
        this.name = name;
    }

    @Column(name = "NAME")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "USER_ID")
    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    @Override
    public void prepareToSerialize() {
    }

    @Transient
    public String getKey() {
        return name;
    }
}
